home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / C / hf^k-2.dms / in.adf / MUIClass.Lha / Include / Classes / TWiMUI / Notify.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-06  |  14.2 KB  |  427 lines

  1. //
  2. //  $VER: Notify.h      1.2 (02 Sep 1996)
  3. //
  4. //    c 1996 Thomas Wilhelmi
  5. //
  6. //
  7. // Address : Taunusstrasse 14
  8. //           61138 Niederdorfelden
  9. //           Germany
  10. //
  11. //  E-Mail : willi@twi.rhein-main.de
  12. //
  13. //   Phone : +49 (0)6101 531060
  14. //   Fax   : +49 (0)6101 531061
  15. //
  16. //
  17. //  $HISTORY:
  18. //
  19. //  16 Jun 1996 :   1.0 : first public Release
  20. //
  21. //  02 Sep 1996 :   1.2 : Neu:
  22. //                        - Die Methode ObjectID() wurde für MUI 3.6 von MUIARea
  23. //                          übernommen.
  24. //                        - Die Methode GetConfigItem() wurde für MUI 3.6 hinzugefügt.
  25. //                        - Die Methode KillNotifyObj() wurde für MUI 3.6 hinzugefügt.
  26. //                        - ClassNum() für Exception-Handling.
  27. //                        Änderungen:
  28. //                        - Sicherstellen das auch wirklich erst die letzte Instanz
  29. //                          eines MUI-Objektes den entsprechenden Dispose ausführt über
  30. //                          TWiShare
  31. //                        - MakeId() aus Konsistenzgründen in MakeID() geändert.
  32. //                        Änderungen
  33. //                        - Parameter des Copy-Konstruktor als 'const'-Parameter definiert
  34. //                        - MUIT aus Konsistenzgründen in MUIErrorX geändert.
  35. //
  36.  
  37. #ifndef CPP_TWIMUI_NOTIFY_H
  38. #define CPP_TWIMUI_NOTIFY_H
  39.  
  40. #ifndef CPP_TWIMUI_MISC_H
  41. #include <classes/twimui/misc.h>
  42. #endif
  43.  
  44. #ifndef INTUITION_CLASSUSR_H
  45. #include <intuition/classusr.h>
  46. #endif
  47.  
  48. #ifndef LIBRARIES_MUI_H
  49. #include <libraries/mui.h>
  50. #endif
  51.  
  52. #ifndef _INCLUDE_PRAGMA_MUIMASTER_LIB_H
  53. #include <pragma/muimaster_lib.h>
  54. #endif
  55.  
  56. #ifndef WORKBENCH_WORKBENCH_H
  57. #include <workbench/workbench.h>
  58. #endif
  59.  
  60. const ULONG MUISERIALNR_WILLI = (ULONG)0x06af;
  61. const ULONG TAGBASE_WILLI     = (TAG_USER | ( MUISERIALNR_WILLI << 16));
  62.  
  63. const ULONG MUIA_TWiClass_AppClass = (TAGBASE_WILLI | 0xffff);
  64. const ULONG MUIA_TWiClass_WinClass = (TAGBASE_WILLI | 0xfffe);
  65.  
  66. const ULONG MUIV_TWiMUI_MUIErrorX_Notify        = 1;
  67. const ULONG MUIV_TWiMUI_MUIErrorX_Family        = 2;
  68. const ULONG MUIV_TWiMUI_MUIErrorX_Menustrip     = 3;
  69. const ULONG MUIV_TWiMUI_MUIErrorX_Menu          = 4;
  70. const ULONG MUIV_TWiMUI_MUIErrorX_Menuitem      = 5;
  71. const ULONG MUIV_TWiMUI_MUIErrorX_Application   = 6;
  72. const ULONG MUIV_TWiMUI_MUIErrorX_Window        = 7;
  73. const ULONG MUIV_TWiMUI_MUIErrorX_Aboutmui      = 8;
  74. const ULONG MUIV_TWiMUI_MUIErrorX_Area          = 9;
  75. const ULONG MUIV_TWiMUI_MUIErrorX_Rectangle     = 10;
  76. const ULONG MUIV_TWiMUI_MUIErrorX_Balance       = 11;
  77. const ULONG MUIV_TWiMUI_MUIErrorX_Image         = 12;
  78. const ULONG MUIV_TWiMUI_MUIErrorX_Bitmap        = 13;
  79. const ULONG MUIV_TWiMUI_MUIErrorX_Bodychunk     = 14;
  80. const ULONG MUIV_TWiMUI_MUIErrorX_Text          = 15;
  81. const ULONG MUIV_TWiMUI_MUIErrorX_Gadget        = 16;
  82. const ULONG MUIV_TWiMUI_MUIErrorX_String        = 17;
  83. const ULONG MUIV_TWiMUI_MUIErrorX_Boopsi        = 18;
  84. const ULONG MUIV_TWiMUI_MUIErrorX_Prop          = 19;
  85. const ULONG MUIV_TWiMUI_MUIErrorX_Gauge         = 20;
  86. const ULONG MUIV_TWiMUI_MUIErrorX_Scale         = 21;
  87. const ULONG MUIV_TWiMUI_MUIErrorX_Colorfield    = 22;
  88. const ULONG MUIV_TWiMUI_MUIErrorX_List          = 23;
  89. const ULONG MUIV_TWiMUI_MUIErrorX_Floattext     = 24;
  90. const ULONG MUIV_TWiMUI_MUIErrorX_Volumelist    = 25;
  91. const ULONG MUIV_TWiMUI_MUIErrorX_Dirlist       = 26;
  92. const ULONG MUIV_TWiMUI_MUIErrorX_Numeric       = 27;
  93. const ULONG MUIV_TWiMUI_MUIErrorX_Knob          = 28;
  94. const ULONG MUIV_TWiMUI_MUIErrorX_Levelmeter    = 29;
  95. const ULONG MUIV_TWiMUI_MUIErrorX_Numericbutton = 30;
  96. const ULONG MUIV_TWiMUI_MUIErrorX_Slider        = 31;
  97. const ULONG MUIV_TWiMUI_MUIErrorX_Pendisplay    = 32;
  98. const ULONG MUIV_TWiMUI_MUIErrorX_Poppen        = 33;
  99. const ULONG MUIV_TWiMUI_MUIErrorX_Group         = 34;
  100. const ULONG MUIV_TWiMUI_MUIErrorX_Register      = 35;
  101. const ULONG MUIV_TWiMUI_MUIErrorX_Penadjust     = 36;
  102. const ULONG MUIV_TWiMUI_MUIErrorX_Virtgroup     = 37;
  103. const ULONG MUIV_TWiMUI_MUIErrorX_Scrollgroup   = 38;
  104. const ULONG MUIV_TWiMUI_MUIErrorX_Scrollbar     = 39;
  105. const ULONG MUIV_TWiMUI_MUIErrorX_Listview      = 40;
  106. const ULONG MUIV_TWiMUI_MUIErrorX_Radio         = 41;
  107. const ULONG MUIV_TWiMUI_MUIErrorX_Cycle         = 42;
  108. const ULONG MUIV_TWiMUI_MUIErrorX_Coloradjust   = 43;
  109. const ULONG MUIV_TWiMUI_MUIErrorX_Palette       = 44;
  110. const ULONG MUIV_TWiMUI_MUIErrorX_Popstring     = 45;
  111. const ULONG MUIV_TWiMUI_MUIErrorX_Popobject     = 46;
  112. const ULONG MUIV_TWiMUI_MUIErrorX_Poplist       = 47;
  113. const ULONG MUIV_TWiMUI_MUIErrorX_Popasl        = 48;
  114. const ULONG MUIV_TWiMUI_MUIErrorX_Semaphore     = 49;
  115. const ULONG MUIV_TWiMUI_MUIErrorX_Dataspace     = 50;
  116. const ULONG MUIV_TWiMUI_MUIErrorX_CreateClass   = 100;
  117.  
  118. inline ULONG MakeID(const UBYTE a, const UBYTE b, const UBYTE c, const UBYTE d)
  119.     {
  120.     return((ULONG)(a)<<24 | (ULONG)(b)<<16 | (ULONG)(c)<<8 | (ULONG)(d));
  121.     };
  122.  
  123. inline Object *MakeLabel(const STRPTR lab)
  124.     {
  125.     return(MUI_MakeObject(MUIO_Label,lab,0));
  126.     };
  127.  
  128. inline Object *MakeLabel1(const STRPTR lab)
  129.     {
  130.     return(MUI_MakeObject(MUIO_Label,lab,MUIO_Label_SingleFrame));
  131.     };
  132.  
  133. inline Object *MakeLabel2(const STRPTR lab)
  134.     {
  135.     return(MUI_MakeObject(MUIO_Label,lab,MUIO_Label_DoubleFrame));
  136.     };
  137.  
  138. inline Object *MakeLLabel(const STRPTR lab)
  139.     {
  140.     return(MUI_MakeObject(MUIO_Label,lab,MUIO_Label_LeftAligned));
  141.     };
  142.  
  143. inline Object *MakeLLabel1(const STRPTR lab)
  144.     {
  145.     return(MUI_MakeObject(MUIO_Label,lab,MUIO_Label_LeftAligned|MUIO_Label_SingleFrame));
  146.     };
  147.  
  148. inline Object *MakeLLabel2(const STRPTR lab)
  149.     {
  150.     return(MUI_MakeObject(MUIO_Label,lab,MUIO_Label_LeftAligned|MUIO_Label_DoubleFrame));
  151.     };
  152.  
  153. inline Object *MakeCLabel(const STRPTR lab)
  154.     {
  155.     return(MUI_MakeObject(MUIO_Label,lab,MUIO_Label_Centered));
  156.     };
  157.  
  158. inline Object *MakeCLabel1(const STRPTR lab)
  159.     {
  160.     return(MUI_MakeObject(MUIO_Label,lab,MUIO_Label_Centered|MUIO_Label_SingleFrame));
  161.     };
  162.  
  163. inline Object *MakeCLabel2(const STRPTR lab)
  164.     {
  165.     return(MUI_MakeObject(MUIO_Label,lab,MUIO_Label_Centered|MUIO_Label_DoubleFrame));
  166.     };
  167.  
  168. inline Object *MakeFreeLabel(const STRPTR lab)
  169.     {
  170.     return(MUI_MakeObject(MUIO_Label,lab,MUIO_Label_FreeVert));
  171.     };
  172.  
  173. inline Object *MakeFreeLabel1(const STRPTR lab)
  174.     {
  175.     return(MUI_MakeObject(MUIO_Label,lab,MUIO_Label_FreeVert|MUIO_Label_SingleFrame));
  176.     };
  177.  
  178. inline Object *MakeFreeLabel2(const STRPTR lab)
  179.     {
  180.     return(MUI_MakeObject(MUIO_Label,lab,MUIO_Label_FreeVert|MUIO_Label_DoubleFrame));
  181.     };
  182.  
  183. inline Object *MakeFreeLLabel(const STRPTR lab)
  184.     {
  185.     return(MUI_MakeObject(MUIO_Label,lab,MUIO_Label_FreeVert|MUIO_Label_LeftAligned));
  186.     };
  187.  
  188. inline Object *MakeFreeLLabel1(const STRPTR lab)
  189.     {
  190.     return(MUI_MakeObject(MUIO_Label,lab,MUIO_Label_FreeVert|MUIO_Label_LeftAligned|MUIO_Label_SingleFrame));
  191.     };
  192.  
  193. inline Object *MakeFreeLLabel2(const STRPTR lab)
  194.     {
  195.     return(MUI_MakeObject(MUIO_Label,lab,MUIO_Label_FreeVert|MUIO_Label_LeftAligned|MUIO_Label_DoubleFrame));
  196.     };
  197.  
  198. inline Object *MakeFreeCLabel(const STRPTR lab)
  199.     {
  200.     return(MUI_MakeObject(MUIO_Label,lab,MUIO_Label_FreeVert|MUIO_Label_Centered));
  201.     };
  202.  
  203. inline Object *MakeFreeCLabel1(const STRPTR lab)
  204.     {
  205.     return(MUI_MakeObject(MUIO_Label,lab,MUIO_Label_FreeVert|MUIO_Label_Centered|MUIO_Label_SingleFrame));
  206.     };
  207.  
  208. inline Object *MakeFreeCLabel2(const STRPTR lab)
  209.     {
  210.     return(MUI_MakeObject(MUIO_Label,lab,MUIO_Label_FreeVert|MUIO_Label_Centered|MUIO_Label_DoubleFrame));
  211.     };
  212.  
  213. inline Object *MakeKeyLabel(const STRPTR lab, const UBYTE key)
  214.     {
  215.     return(MUI_MakeObject(MUIO_Label,lab,key));
  216.     };
  217.  
  218. inline Object *MakeKeyLabel1(const STRPTR lab, const UBYTE key)
  219.     {
  220.     return(MUI_MakeObject(MUIO_Label,lab,MUIO_Label_SingleFrame|(key)));
  221.     };
  222.  
  223. inline Object *MakeKeyLabel2(const STRPTR lab, const UBYTE key)
  224.     {
  225.     return(MUI_MakeObject(MUIO_Label,lab,MUIO_Label_DoubleFrame|(key)));
  226.     };
  227.  
  228. inline Object *MakeKeyLLabel(const STRPTR lab, const UBYTE key)
  229.     {
  230.     return(MUI_MakeObject(MUIO_Label,lab,MUIO_Label_LeftAligned|(key)));
  231.     };
  232.  
  233. inline Object *MakeKeyLLabel1(const STRPTR lab, const UBYTE key)
  234.     {
  235.     return(MUI_MakeObject(MUIO_Label,lab,MUIO_Label_LeftAligned|MUIO_Label_SingleFrame|(key)));
  236.     };
  237.  
  238. inline Object *MakeKeyLLabel2(const STRPTR lab, const UBYTE key)
  239.     {
  240.     return(MUI_MakeObject(MUIO_Label,lab,MUIO_Label_LeftAligned|MUIO_Label_DoubleFrame|(key)));
  241.     };
  242.  
  243. inline Object *MakeKeyCLabel(const STRPTR lab, const UBYTE key)
  244.     {
  245.     return(MUI_MakeObject(MUIO_Label,lab,MUIO_Label_Centered|(key)));
  246.     };
  247.  
  248. inline Object *MakeKeyCLabel1(const STRPTR lab, const UBYTE key)
  249.     {
  250.     return(MUI_MakeObject(MUIO_Label,lab,MUIO_Label_Centered|MUIO_Label_SingleFrame|(key)));
  251.     };
  252.  
  253. inline Object *MakeKeyCLabel2(const STRPTR lab, const UBYTE key)
  254.     {
  255.     return(MUI_MakeObject(MUIO_Label,lab,MUIO_Label_Centered|MUIO_Label_DoubleFrame|(key)));
  256.     };
  257.  
  258. inline Object *MakeFreeKeyLabel(const STRPTR lab, const UBYTE key)
  259.     {
  260.     return(MUI_MakeObject(MUIO_Label,lab,MUIO_Label_FreeVert|(key)));
  261.     };
  262.  
  263. inline Object *MakeFreeKeyLabel1(const STRPTR lab, const UBYTE key)
  264.     {
  265.     return(MUI_MakeObject(MUIO_Label,lab,MUIO_Label_FreeVert|MUIO_Label_SingleFrame|(key)));
  266.     };
  267.  
  268. inline Object *MakeFreeKeyLabel2(const STRPTR lab, const UBYTE key)
  269.     {
  270.     return(MUI_MakeObject(MUIO_Label,lab,MUIO_Label_FreeVert|MUIO_Label_DoubleFrame|(key)));
  271.     };
  272.  
  273. inline Object *MakeFreeKeyLLabel(const STRPTR lab, const UBYTE key)
  274.     {
  275.     return(MUI_MakeObject(MUIO_Label,lab,MUIO_Label_FreeVert|MUIO_Label_LeftAligned|(key)));
  276.     };
  277.  
  278. inline Object *MakeFreeKeyLLabel1(const STRPTR lab, const UBYTE key)
  279.     {
  280.     return(MUI_MakeObject(MUIO_Label,lab,MUIO_Label_FreeVert|MUIO_Label_LeftAligned|MUIO_Label_SingleFrame|(key)));
  281.     };
  282.  
  283. inline Object *MakeFreeKeyLLabel2(const STRPTR lab, const UBYTE key)
  284.     {
  285.     return(MUI_MakeObject(MUIO_Label,lab,MUIO_Label_FreeVert|MUIO_Label_LeftAligned|MUIO_Label_DoubleFrame|(key)));
  286.     };
  287.  
  288. inline Object *MakeFreeKeyCLabel(const STRPTR lab, const UBYTE key)
  289.     {
  290.     return(MUI_MakeObject(MUIO_Label,lab,MUIO_Label_FreeVert|MUIO_Label_Centered|(key)));
  291.     };
  292.  
  293. inline Object *MakeFreeKeyCLabel1(const STRPTR lab, const UBYTE key)
  294.     {
  295.     return(MUI_MakeObject(MUIO_Label,lab,MUIO_Label_FreeVert|MUIO_Label_Centered|MUIO_Label_SingleFrame|(key)));
  296.     };
  297.  
  298. inline Object *MakeFreeKeyCLabel2(const STRPTR lab, const UBYTE key)
  299.     {
  300.     return(MUI_MakeObject(MUIO_Label,lab,MUIO_Label_FreeVert|MUIO_Label_Centered|MUIO_Label_DoubleFrame|(key)));
  301.     };
  302.  
  303. inline Object *MakeHBar(const ULONG size)
  304.     {
  305.     return(MUI_MakeObject(MUIO_HBar,size));
  306.     };
  307.  
  308. inline Object *MakeVBar(const ULONG size)
  309.     {
  310.     return(MUI_MakeObject(MUIO_VBar,size));
  311.     };
  312.  
  313. inline Object *MakeHSpace(const ULONG size)
  314.     {
  315.     return(MUI_MakeObject(MUIO_HSpace,size));
  316.     };
  317.  
  318. inline Object *MakeVSpace(const ULONG size)
  319.     {
  320.     return(MUI_MakeObject(MUIO_VSpace,size));
  321.     };
  322.  
  323. class MUIErrorX
  324.     {
  325.     private:
  326.         TWiStr ClassName;
  327.         ULONG Typ;
  328.         LONG Error;
  329.     public:
  330.         MUIErrorX(const TWiStr &c, const ULONG t) : ClassName(c), Typ(t), Error(MUI_Error()) { };
  331.         MUIErrorX(const MUIErrorX &t) : ClassName(t.ClassName), Typ(t.Typ), Error(t.Error) { };
  332.         ~MUIErrorX() { };
  333.         const TWiStr &name() const { return(ClassName); };
  334.         ULONG typ() const { return(Typ); };
  335.         LONG error() const { return(Error); };
  336.     };
  337.  
  338. class MUILabelHelp
  339.     {
  340.     private:
  341.         TWiStr labstr;
  342.         UBYTE cc;
  343.     protected:
  344.         MUILabelHelp(const STRPTR);
  345.         MUILabelHelp(const MUILabelHelp &p) : labstr(p.labstr), cc(p.cc) { };
  346.         virtual ~MUILabelHelp();
  347.         MUILabelHelp &operator=(const MUILabelHelp &);
  348.         TWiStr &gLab() { return(labstr); };
  349.         UBYTE gCC() { return(cc); };
  350.     };
  351.  
  352. class MUIApplication;
  353.  
  354. class MUINotify
  355.     {
  356.     private:
  357.         static TWiArrayList<MUI_CustomClass *> ClassArray;
  358.         static ULONG Counter;
  359.         static ULONG dispatcher(register __a0 struct IClass *, register __a2 Object *, register __a1 Msg);
  360.  
  361.     private:
  362.         TWiStr ClassName;
  363.         struct MUI_CustomClass *mcc;
  364.     protected:
  365.         TWiTag Tags;
  366.         Object *Obj;
  367.         Object *Par;
  368.  
  369.     private:
  370.         void createclass();
  371.         void terminate();
  372.         virtual ULONG Dispatch(struct IClass *, Object *, Msg);
  373.         virtual const ULONG ClassNum() const;
  374.     protected:
  375.         MUINotify(const STRPTR cl);
  376.         MUINotify(const MUINotify &);
  377.         virtual ~MUINotify();
  378.         MUINotify &operator= (const MUINotify &);
  379.         void set(const Tag, const ULONG);
  380.         ULONG get(const Tag, const ULONG p = NULL) const;
  381.         ULONG dom(const Tag);
  382.         ULONG dom(const Tag, ULONG);
  383.         ULONG dom(const Tag, ULONG, ULONG);
  384.         ULONG dom(const Tag, ULONG, ULONG, ULONG);
  385.         ULONG dom(const Tag, ULONG, ULONG, ULONG, ULONG);
  386.         ULONG dom(const Tag, ULONG, ULONG, ULONG, ULONG, ULONG);
  387.         ULONG dom(const Tag, ULONG, ULONG, ULONG, ULONG, ULONG, ULONG);
  388.         ULONG dom(const Tag, ULONG, ULONG, ULONG, ULONG, ULONG, ULONG, ULONG);
  389.         void init(const struct TagItem *);
  390.         void init(const Tag, ...);
  391.         virtual ULONG Dispose(struct IClass *, Object *, Msg);
  392.         virtual ULONG UserDispatch(struct IClass *, Object *, Msg);
  393.     public:
  394.         BOOL Create(const struct TagItem *t = NULL);
  395.         BOOL Create(const Tag, ...);
  396.         Object *object() const { return(Obj); };
  397.         operator Object*() const { return(Obj); };
  398.         Object *AppObject() const { return((Object *)get(MUIA_ApplicationObject)); };
  399.         MUIApplication *AppClass() const;
  400.         struct AppMessage *AppMessage() const { return((struct AppMessage *)get(MUIA_AppMessage)); };
  401.         void HelpLine(const LONG p) { set(MUIA_HelpLine,(ULONG)p); };
  402.         LONG HelpLine() const { return((LONG)get(MUIA_HelpLine,0L)); };
  403.         void HelpNode(const STRPTR p) { set(MUIA_HelpNode,(ULONG)p); };
  404.         STRPTR HelpNode() const { return((STRPTR)get(MUIA_HelpNode)); };
  405.         void ObjectID(const ULONG p) { set(MUIA_ObjectID,p); };
  406.         ULONG ObjectID() const { return(get(MUIA_ObjectID,0L)); };
  407.         Object *Parent() const { return((Object *)get(MUIA_Parent)); };
  408.         LONG Revision() const { return((LONG)get(MUIA_Revision,0L)); };
  409.         void UserData(const ULONG p) { set(MUIA_UserData,p); };
  410.         ULONG UserData() const { return(get(MUIA_UserData,0L)); };
  411.         LONG VersionN() const { return((LONG)get(MUIA_Version,0L)); };
  412.         void CallHook(struct Hook *h, ULONG c = 0UL, ...);
  413.         Object *FindUData(ULONG p) { return((Object *)dom(MUIM_FindUData,p)); };
  414.         ULONG GetConfigItem(ULONG p) { ULONG r; dom(MUIM_GetConfigItem,p,(ULONG)&r); return(r); };
  415.         ULONG GetUData(ULONG p1, ULONG *p2) { return(dom(MUIM_GetUData,p1,(ULONG)p2)); };
  416.         void KillNotify(ULONG p) { dom(MUIM_KillNotify,p); };
  417.         void KillNotifyObj(ULONG p1, Object *p2) { dom(MUIM_KillNotifyObj,p1,(ULONG)p2); };
  418.         void NoNotifySet(ULONG p1, ULONG p2) { dom(MUIM_NoNotifySet,p1,p2); };
  419.         void Notify(const Tag t, ULONG v, Object *o, ULONG c = 0UL, ...);
  420.         void Set(ULONG p1, ULONG p2) { dom(MUIM_Set,p1,p2); };
  421.         void SetAsString(Tag t, STRPTR f, ULONG c = 0UL, ...);
  422.         void SetUData(ULONG p1, ULONG p2, ULONG p3) { dom(MUIM_SetUData,p1,p2,p3); };
  423.         void SetUDataOnce(ULONG p1, ULONG p2, ULONG p3) { dom(MUIM_SetUDataOnce,p1,p2,p3); };
  424.     };
  425.  
  426. #endif
  427.